support for __all__
filtering with from ... import *
#10518
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
__all__
withfrom ... import *
#10516.Circuitpython does not support filtering
from someModule import *
when someModule contains__all__ = ['symbol1', 'symbol2', ...]
. This results in importing more symbols than intended, which can cause a little wasted memory (entries in the globals() in the scope containingfrom someModule import *
) and differs from CPython in ways that can introduce subtle bugs (primarily through unexpected replacement of existing symbols).This includes an enhanced mp_import_all(...) in py/runtime.c to support
from ... import *
filtering when__all__ = [...]
is present.I have basic tests (which it passes) for the following:
__all__
are not imported)__all__
will throw TypeError__all__
(i.e.__all__ = ['hello','world']
where world is undefined) will throw AttributeErrorbut I'm not sure where/how to add them so they become part of the CircuitPython CI testing pipeline
I also have a few things that I got "working" through trial and error which might have more efficient / recognizable patterns available. For example:
__all__
__all__
for lookup key